using UnityEngine;
using System.Collections;

public class mummy : MonoBehaviour {

    public float vel;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		 if(Player.player != null)
	     MummyMoviment(transform,Player.player.transform,vel, 3);
	}
	
	public void MummyMoviment(Transform mummy, Transform player, float vel, float distance)
    {
		if(player != null)
		{
		 vel *= Time.deltaTime;
	     
		 if(player.position.x > mummy.position.x - distance && player.position.x < mummy.position.x)
		 {
			mummy.Translate(-vel,0,0);
		 }
		 
		 if(player.position.x < mummy.position.x + distance && player.position.x > mummy.position.x)
		 {
			mummy.Translate(vel,0,0);
		 }
		}
    }
}
